-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable mouse input when the debugger interaction tool is active #2209
Disable mouse input when the debugger interaction tool is active #2209
Conversation
FlxG.mouse.enabled will temporarily return false if the debugger interaction tool is active (visible). FlxButton (and any subclass) and FlxMouseEventManager will now account for FlxG.mouse.enabled when dealing with states, so clickable elements related to those will not work when the debugger interaction tool is active.
Hm, I think it would be a lot cleaner to en- and disable as needed, instead of |
Agreed, that way is much better. In such case, the interaction tool should keep track of the current value of |
You mean in case the user has set the value? That's currently not done, nor is it done for |
Yeah, in case the user has set it. But since that is not the case, I'll just set true/false accordingly. |
@@ -483,10 +483,15 @@ class FlxDebugger extends Sprite | |||
@:allow(flixel.system.debug) | |||
function onMouseFocusLost():Void | |||
{ | |||
#if FLX_MOUSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor complaint, but it looks we just need a single FLX_MOUSE
check for this entire function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, no need for two checks.
CI is failing in |
Oh, so the CI failure is legit for once. Usually it's just random failures... |
Have you had a chance to look at the test failure yet? Updated the branch to latest dev, but it's still happening. |
Not yet, I'm sorry. I can check on it this weekend. |
It seems the cpp targets are still failing (now on a different test cases). When I run the tests locally (Win10, Haxe 3.4.7, Haxeflixel dev) they all pass though. Am I missing anything? |
When FlxG.mouse.enabled is false, FlxMouseEventManager will continue to handle over and out events, but will ignore all other events. It allows tracked objects to be in a consistent state when mouse input is disabled, e.g. the interaction tool becomes active and buttons should stop working.
I think it is finally working. |
#if FLX_MOUSE | ||
// Debugger is visible, allow mouse input in the game only if the | ||
// interaction tool is not active. | ||
FlxG.mouse.enabled = !FlxG.game.debugger.interaction.visible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit annoying - just because it's visible doesn't mean it's actively being used. I'd like to still be able to interact with buttons as long as none of the interaction tools are selected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I'll change that.
Looks good to me now, thanks! 👍 |
Thank you for all the feedback and for merging this PR! 🎉 |
Nice catch! I'll get that leftover soon :D |
FlxG.mouse.enabled
will temporarily returnfalse
if the debugger interaction tool is active (visible).FlxButton
(and any subclass) andFlxMouseEventManager
will now account forFlxG.mouse.enabled
when dealing with states, so clickable elements related to those will not work when the debugger interaction tool is active.I decided to preserve the state of clickable elements when the debugger interaction tool becomes active, i.e. over remains over instead of released. I think it makes more sense to developers to not have a lot of state changes fired when the debugger is enabled. If you dislike this approach, let me know so I can adapt the code to no preserve the state of clickable elements.
Fixes: #2155